Repository navigation
[Feature][Relax] Support shared-KV attention with configurable sliding windows - #20121
Merged
Merged
Conversation
akaashrp
force-pushed
the
gemma4-audio-tvm-upstream
branch
from
August 12, 2026 03:54
e6f54fa to
5d6848b
Compare
Replace the hard-coded 1024-token per-layer window with a cache configuration value. Use the configured value consistently when selecting pages, computing page offsets and RoPE positions, and masking the past-cache portion of chunked prefill. Keep the five-field runtime configuration backward compatible, preserve the existing positional constructor arguments, and cover both CPU end-to-end attention and the sliding prefill mask on CUDA/Metal targets.
Add a paged-KV-cache operation for logical layers that reuse another layer's K/V. The source layer owns and appends the cache; dependent layers provide their queries and the source layer's current-chunk K/V without allocating or appending a second cache.\n\nDefine the frontend and runtime ABI directly as attention_with_shared_kv and validate both ordinary MHA and per-layer sliding MHA against a NumPy reference.
akaashrp
force-pushed
the
gemma4-audio-tvm-upstream
branch
from
August 12, 2026 10:21
5d6848b to
3f31be6
Compare
tlopex
approved these changes
Aug 12, 2026
wodylm
pushed a commit
to wodylm/mcTVM
that referenced
this pull request
Sep 15, 2026
…g windows (apache#20121) Extend `PagedKVCache` for models whose logical attention layers reuse K/V cached by another physical layer. - Adds non-mutating `attention_with_shared_kv` support. - Makes per-layer sliding-window size configurable. - Corrects sliding-window masking during chunked prefill. This is intended to enable downstream Gemma 4 support in MLC-LLM and WebLLM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extend
PagedKVCachefor models whose logical attention layers reuse K/V cached by another physical layer.attention_with_shared_kvsupport.This is intended to enable downstream Gemma 4 support in MLC-LLM and WebLLM.